package vos;

import java.util.Collections;
import java.util.List;

public class Page<T> {

    public static Page EMPTY = new Page();
    
    public int pageNo = 1;
    public int pageSize = 1;

    public int startIndex;
    public int totalCount;
    public int totalPageCount;
    public List<T> items = Collections.EMPTY_LIST;

    public static <T> Page<T> newInstance(int pageNo, int pageSize, int totalCount) {
        Page page = new Page();
        page.pageNo = pageNo;
        page.pageSize = pageSize;
        page.totalCount = totalCount;
        return page;
    }

    public int getStartIndex(int pag,int rows) {
        if (pag > 0) {
            return rows * (pag - 1);
        }
        return 0;
    }

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getTotalPageCount() {
		return totalPageCount;
	}

	public void setTotalPageCount(int totalPageCount) {
		this.totalPageCount = totalPageCount;
	}

	public List<T> getItems() {
		return items;
	}

	public void setItems(List<T> items) {
		this.items = items;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
    
}
